Skip to content

fix(anthropic): drop invalid name field from output_config.format - #33

Open
adilson0888 wants to merge 1 commit into
AmazingAng:mainfrom
adilson0888:fix/anthropic-structured-output-extra-name-field
Open

fix(anthropic): drop invalid name field from output_config.format#33
adilson0888 wants to merge 1 commit into
AmazingAng:mainfrom
adilson0888:fix/anthropic-structured-output-extra-name-field

Conversation

@adilson0888

Copy link
Copy Markdown

Fixes #32.

Problem

Structured-output requests (response_format.json_schema on /v1/chat/completions, text.format on /v1/responses) to the anthropic provider fail outright against the live Anthropic API:

{"error":{"message":"output_config.format.name: Extra inputs are not permitted","type":"invalid_request_error"}}

Anthropic's Messages API output_config.format only accepts { type, schema }. The translator was carrying over an OpenAI-style name field (valid on OpenAI's json_schema.name/text.format.name, not on Anthropic's shape) into the Anthropic request body, and Anthropic's strict validation rejects the unrecognized field.

Fix

Drops name from both call sites that build output_config.format for Anthropic:

  • openaiToAnthropic (Chat Completions → Anthropic)
  • responsesToAnthropic (Responses API → Anthropic)

No other fields change. The equivalent OpenAI-Responses-shaped path (chatToResponsesRequest, text.format.name) is untouched — that field is correct there, it's a different upstream (OpenAI) with a different accepted shape.

Also fixes a stale unit test that had asserted the buggy behavior (result.output_config.format.name === "test").

Verification

  • Reproduced the original 400 against the live Anthropic API via a real Karakeep auto-tagging request (claude-haiku-4-5, /v1/chat/completions with response_format.json_schema).
  • Applied this exact fix, rebuilt, redeployed — same request now returns a real completion instead of a 400.
  • Confirmed end-to-end with Karakeep's actual auto-tagging feature working against the patched build.
  • Full test suite passes: npm test → 200/200.

Notes

I initially mis-diagnosed this and tried renaming the field to output_format" — Anthropic's own error message corrected that ("This field is deprecated. Use 'output_config.format' instead"), confirming output_config.formatis the current wrapper and the sole problem is the extraname` key inside it. Mentioning in case anyone else goes down the same wrong path from the error text.

Anthropic's Messages API structured-output field, output_config.format,
only accepts { type, schema }. Sending the extra `name` field (carried
over from OpenAI's json_schema.name / text.format.name conventions)
causes the live API to reject every structured-output request from the
anthropic provider with:

  400 output_config.format.name: Extra inputs are not permitted

Reproduced against the real API via a Karakeep auto-tagging request
routed through the anthropic provider (claude-haiku-4-5, /v1/chat/completions
with response_format.json_schema). Confirmed the fix resolves it end-to-end
against the live API, then updated the stale unit test that had asserted
the buggy behavior.

Affects both translator paths that build Anthropic requests:
- openaiToAnthropic (Chat Completions -> Anthropic)
- responsesToAnthropic (Responses API -> Anthropic)

The equivalent OpenAI-Responses-shaped output (chatToResponsesRequest,
text.format.name) is untouched -- that field is valid for OpenAI's own
Responses API and unrelated to this bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Anthropic structured output (response_format.json_schema) fails with "output_config.format.name: Extra inputs are not permitted"

1 participant